package com.yanqu.road.server.cmd.beauty;

import com.yanqu.road.server.pb.BeautyPb;
import com.yanqu.road.entity.config.beauty.BeautyTrystResult;
import com.yanqu.road.pb.beauty.BeautyProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.BeautyModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.server.command.Cmd;

@Cmd(code = Protocol.S_BEAUTY_TRYST, desc = "美女传唤")
public class BeautyTrystCmd extends AbstractCommand {

    private int type;

    private BeautyTrystResult result;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        BeautyProto.BeautyTrystReqMsg req = BeautyProto.BeautyTrystReqMsg.parseFrom(packet.getBytes());
        type = req.getType();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        result = player.getModule(BeautyModule.class).beautyTryst(type, false);
    }

    @Override
    public void sendData(GamePlayer player) {
        BeautyProto.BeautyTrystRespMsg.Builder respMsg = BeautyPb.parseBeautyTrystRespMsg(result);
        if(null != respMsg) {
            player.sendPacket(Protocol.U_BEAUTY_TRYST, respMsg);
        }
    }
}
